import sqlite3

con = sqlite3.connect("user.db", check_same_thread = False)
cur = con.cursor()

def init():
    con = sqlite3.connect("user.db")
    cur = con.cursor()
    sql = "CREATE TABLE IF NOT EXISTS user(" \
      "id INTEGER PRIMARY KEY autoincrement," \
      "mid INTEGER," \
      "name VARCHAR," \
      "sign VARCHAR," \
      "level INTEGER)"
    cur.execute(sql)

def insert(mid, name, sign, level):
    cur.execute("INSERT INTO user (`mid`, `name`, `sign`, `level`) "
                "values(?,?,?,?)", (mid, name, sign, level))
    con.commit()

def select(type, id):
    if (type == "mid"):
        cur.execute("SELECT * FROM user WHERE id = ?", (id,))
        return cur.fetchall()
    if (type == "level"):
        cur.execute("SELECT * FROM user WHERE level = ?", (id,))
        return cur.fetchall()

def selectAll():
    cur.execute("SELECT * FROM user")
    return cur.fetchall()

if __name__ == '__main__':
    a = selectAll()
    print (a)